package com.hinnotek.amoeba.viewmodels


import androidx.lifecycle.viewModelScope
import com.hinnotek.amoeba.base.BaseBean
import com.hinnotek.amoeba.bean.old.AmibaReimburseByIdBean
import com.hinnotek.amoeba.bean.old.AmibaReimbursePageByUserIdBean
import com.hinnotek.amoeba.repo.AmibaReimburseRepo
import com.lee.common.base.BaseViewModel
import com.lee.common.network.net.StateLiveData
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.launch
import okhttp3.RequestBody
import javax.inject.Inject

@HiltViewModel
class AmibaReimburseViewModel  @Inject constructor(private val repository: AmibaReimburseRepo) :
    BaseViewModel() {

    private val baseData = StateLiveData<BaseBean>()
    private val baseData2 = StateLiveData<BaseBean>()
    private val baseData3 = StateLiveData<BaseBean>()
    private val baseData4 = StateLiveData<BaseBean>()

    fun updateAmibaReimburse(body: RequestBody): StateLiveData<BaseBean> {
        viewModelScope.launch {
            repository.updateAmibaReimburse(body, baseData)
        }
        return baseData
    }

    private val amibaReimbursePageByUserIdData = StateLiveData<MutableList<AmibaReimbursePageByUserIdBean>>()
    fun getAmibaReimbursePageByUserId(body: RequestBody): StateLiveData<MutableList<AmibaReimbursePageByUserIdBean>> {
        viewModelScope.launch {
            repository.getAmibaReimbursePageByUserId(body, amibaReimbursePageByUserIdData)
        }
        return amibaReimbursePageByUserIdData
    }

    private val amibaReimburseByIdData = StateLiveData<AmibaReimburseByIdBean>()
    fun getAmibaReimburseById(amibaReimburseId: Int): StateLiveData<AmibaReimburseByIdBean> {
        viewModelScope.launch {
            repository.getAmibaReimburseById(amibaReimburseId, amibaReimburseByIdData)
        }
        return amibaReimburseByIdData
    }


    fun backAmibaReimburse(amibaReimburseId: Int) :StateLiveData<BaseBean>{
        viewModelScope.launch {
            repository.backAmibaReimburse(amibaReimburseId, baseData3)
        }
        return baseData3
    }

    fun resubmitAmibaReimburse(amibaReimburseId: Int):StateLiveData<BaseBean> {
        viewModelScope.launch {
            repository.resubmitAmibaReimburse(amibaReimburseId, baseData4)
        }
        return baseData4
    }

    fun addAmibaReimburse(requestBody: RequestBody) :StateLiveData<BaseBean>{
        viewModelScope.launch {
            repository.addAmibaReimburse(requestBody, baseData2)
        }
        return  baseData2
    }


}